package com.lxl.hadoop.wc;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

/**
 * @Author lixilin
 * @Date 2022/1/1 9:20
 * @Description
 */
public class WcCombiner extends Reducer<Text, IntWritable,Text, IntWritable> {
    IntWritable v = new IntWritable();
    protected void reduce(Text key, Iterable<IntWritable> values, Context context
    ) throws IOException, InterruptedException {
        // cls 1
        int num =0;
        for (IntWritable value : values) {
            num += value.get();
        }
        v.set(num);
        context.write(key,v);
    }
}
